package utility;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class  StringUtil  {
	
	/**
     * filter nhung ki tu dac biet
     *
	*/
	public static String filter(String value) {
        byte newLine[] = { 10 };
        if (value == null) return null;
        value = value.trim();
        char content[] = new char[value.length()];
        value.getChars(0, value.length(), content, 0);
        StringBuffer result = new StringBuffer(content.length + 50);
        for (int i = 0; i < content.length; i++)
            switch (content[i]) {
                case 59: // ';'
                    result.append("&#59;");
                    break;
                case 60: // '<'
                    result.append("&lt;");
                    break;

                case 62: // '>'
                    result.append("&gt;");
                    break;

                case 38: // '&'
                    result.append("&amp;");
                    break;

                case 34: // '"'
                    result.append("&quot;");
                    break;

                case 39: // '\''
                    result.append("&rsquo;");
                    break;

                case 37: // '%''
                    result.append("&#37;");
                    break;
                case 92: // '\\'
                    result.append("&#92;");
                    break;
                    // End of add
                case 58: // ':'
                    result.append("&#58;");
                    break;
                case 13:
                    result.append(new String(newLine));
                    break;

                case 10:
                    if ((i > 0) && (content[i - 1] != 13)) {
                        result.append(new String(newLine));
                    }
                    break;

                default:
                    result.append(content[i]);
                    break;
            }

        return result.toString();
    }

    public static boolean findPercentage(String value) {
        if (isNullOrBlankString(value)) return false;
        value = value.trim();
        char content[] = new char[value.length()];
        value.getChars(0, value.length(), content, 0);
        for (int i = 0; i < content.length; i++) {
            switch (content[i]) {
                case 37: // '%'
                    return true;
            }
        }
        return false;

    }

    /*
     * This function get THONG_KE_CA_NHAN_FORM
     */
    public static String findSpecific(String value) {
        if (isNullOrBlankString(value)) return null;
        value = value.trim();
        char content[] = new char[value.length()];
        value.getChars(0, value.length(), content, 0);
        StringBuffer result = new StringBuffer(content.length + 50);
        for (int i = 0; i < content.length; i++) {
            switch (content[i]) {
                case 92: // '\'
                    result.append("\\\\");
                    break;
                case 37: // '%'
                    result.append("/%");
                    break;
                default:
                    result.append(content[i]);
                    break;
            }
        }
        return result.toString();
    }

    /**
     * Get filter some specific character
     *
     */
    public static String getfilter(String value) {
        // Check null value
        if (isNullOrBlankString(value))
            return "";
        value = value.trim();
        // Get specific character
        value = value.replaceAll("&lt;", "<");
        value = value.replaceAll("&gt;", ">");
        value = value.replaceAll("&amp;", "&");
        value = value.replaceAll("&rsquo;", "\'");
        value = value.replaceAll("&#58;", ":");
        value = value.replaceAll("&#37;", "%");
        // Process " char
        char data[] = { '"' };
        String str = new String(data);
        value = value.replaceAll("&quot;", str);

        // char a[] = {'\\'};
        // str = new String(a);
        // value = value.replaceAll("&#92;",str);
        return value;
    }

    
    /**
     * This method confirm String is null or "" number
     *
     * return boolean value
     */
    public static boolean isNullOrBlankString(String str) {
        boolean result = false;
        if ("".equals(str) || str == null) {
            result = true;
        }
        return result;
    }

    /**
     * This method confirm condition get information from and validate email
     *
     * @throws NumberFormatException
     *             return number confirm email if validate email is true return
     *             1 else return 0
     */
    public static int confirmFormatEmail(String email) {
        // This method uses object Stringtokennizer to split THONG_KE_CA_NHAN_FORM
        StringTokenizer subEmail = new StringTokenizer(email, "@");
        if (subEmail.countTokens() != 2)
            return 0;
        // This variable find '.' in next Stringtokenizer
        String confirmEmai = (String) subEmail.nextToken();
        confirmEmai = (String) subEmail.nextToken();
        // Confirm have more than 2 ".."
        subEmail = new StringTokenizer(confirmEmai, ".");
        if (subEmail.countTokens() != 2)
            return 0;
        if (!isValidEmail(email))
            return 0;
        return 1;
    }

    public static boolean isPhoneFormat(String strValue) {
        String regex = "^\\d{1,4}+-\\d{1,4}+-\\d{1,4}$";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(strValue);
        return m.matches();
    }

    /**
     * This method confirm condition get information from and validate phone
     * number
     *
     * @throws NumberFormatException
     *             return number confirm if validate is true return 1 else
     *             return 0
     */
    public static int confirmphonenumber(String phoneNumber) {
        // Confirm length of phone number
        if (phoneNumber.length() > 14)
            return 0;
        StringTokenizer subPhonenumber = new StringTokenizer(phoneNumber, "-");
        // Confirm phone number haves more than 2 @
        if (subPhonenumber.countTokens() != 3)
            return 0;
        // Confirm String is Number
        String confirmNumber;
        while (subPhonenumber.hasMoreTokens()) {
            confirmNumber = subPhonenumber.nextToken();
            // Confirm THONG_KE_CA_NHAN_FORM is an Interger
            try {
                Integer.parseInt(confirmNumber);
            } catch (NumberFormatException nfe) {
                return 0;
            }
        }
        if (!isPhoneFormat(phoneNumber))
            return 0;
        return 1;
    }

    /**
     * Read user name
     *
     * @param fileName
     *            this parameter is path os file
     * @return get user name
     */
    public static String readUsername(String fileName) {
        String line;
        String username = "";
        String data = "";
        // Get name of user and throws exception if have errors
        try {
            // Create BufferedReader
            BufferedReader in = new BufferedReader(new FileReader(fileName));
            // Read file
            line = in.readLine();
            data = (String.valueOf(line));
            int index = data.indexOf("=");
            if (index != -1) {
                username = data.substring(index + 1, data.length());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException ex) {
        }
        return username;
    }

    /**
     * Read password of admin
     *
     * @param fileName
     *            this parameter is path of file
     * @return get password of admin
     */
    public static String readPassword(String fileName) {
        String line;
        String password = "";
        String data = "";
        try {
            // Create BufferedReader
            BufferedReader in = new BufferedReader(new FileReader(fileName));
            // Read file
            line = in.readLine();
            line = in.readLine();
            data = (String.valueOf(line));

            int index = data.indexOf("=");
            if (index != -1) {
                password = data.substring(index + 1, data.length());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException ex) {
        }
        return password;
    }

    public static Long convertToLong(String stringValue){
        if(stringValue==null)
            return Long.reverse(0);
        try{
            return Long.parseLong(stringValue);
        }
        catch(Exception e){
//            e.printStackTrace();
            return Long.reverse(0);
        }
    }


    public static String parseLong(Long longValue) {
        return longValue!=null?longValue.toString():null;
    }

    public static String trimString(String string){
        if(string==null )
            return null;
        String result =string.trim();
        if(result.equals(""))
            result=null;
        return result;
    }


	public static String toString(String str, int length) {
        if (null == str) {
            return "";
        }
        if (str.length() > length) {
            return str.substring(0, length) + "...";
        }
        return str;
    }

    public static boolean isStringLonger(String str, int maxLength) {
        if (str != null) {
            String tempString = str;
            tempString = tempString.replaceAll("&quot;", "1").replaceAll("&gt;", "<").replaceAll("&lt;", ">")
                    .replaceAll("&#39;", "1").replaceAll("&amp;", "&");
            return (tempString.length() > maxLength) ? true : false;
        } else {
            return false;
        }
    }
    
    public static String formatNumber(String s) {
          String tempResult = s;
          if (s == null || s.length() == 0 || s.length() < 4)
              return tempResult;

          String COMMA = ",";
          StringBuffer buff = new StringBuffer();

          Map map = new HashMap();

          int length = tempResult.length();
          int l = 0;

          while (true) {
              if (length < 4) {
                  map.put(new Integer(l), tempResult);
                  break;
              } else {
                  String s1 = tempResult.substring(length - 3);
                  map.put(new Integer(l), s1);
                  l++;
                  tempResult = tempResult.substring(0, length - 3);
                  length = tempResult.length();
              }
          }          
          for (int i = map.size() - 1; i >= 0; i--) {
              buff.append((String) map.get(new Integer(i)));
              if (i > 0) {
                  buff.append(COMMA);
              }
          }
          return buff.toString();
      }


    public static String checkString(String str) {
        String[] old = { "&", "<", ">", "\n" };
        String[] strNew = { "&amp;", "&lt;", "&gt;", "<br>" };
        return replace(str, old, strNew);
    }


    public static String replace(String s, char oldSub, char newSub) {
        return replace(s, oldSub, new Character(newSub).toString());
    }

    public static String replace(String s, char oldSub, String newSub) {
        if ((s == null) || (newSub == null)) {
            return null;
        }

        char[] c = s.toCharArray();

        StringBuffer sb = new StringBuffer();

        for (int i = 0; i < c.length; i++) {
            if (c[i] == oldSub) {
                sb.append(newSub);
            } else {
                sb.append(c[i]);
            }
        }

        return sb.toString();
    }

    public static String replace(String s, String oldSub, String newSub) {
        if ((s == null) || (oldSub == null) || (newSub == null)) {
            return null;
        }

        int y = s.indexOf(oldSub);

        if (y >= 0) {
            StringBuffer sb = new StringBuffer();
            int length = oldSub.length();
            int x = 0;

            while (x <= y) {
                sb.append(s.substring(x, y));
                sb.append(newSub);
                x = y + length;
                y = s.indexOf(oldSub, x);
            }

            sb.append(s.substring(x));

            return sb.toString();
        } else {
            return s;
        }
    }

    public static String replace(String s, String[] oldSubs, String[] newSubs) {
        if ((s == null) || (oldSubs == null) || (newSubs == null)) {
            return null;
        }

        if (oldSubs.length != newSubs.length) {
            return s;
        }

        for (int i = 0; i < oldSubs.length; i++) {
            s = replace(s, oldSubs[i], newSubs[i]);
        }

        return s;
    }


    public static String getNull(Integer parameter){
        if(parameter == null) return "";
        return parameter.toString();
    }

    public static String getNameWithNotBlank(String parameter){
        if(StringUtil.isNullOrBlankString(parameter)) return null;
        parameter = TextConverter.toEnglish(parameter).toUpperCase();
        parameter = parameter.trim();
        int y = parameter.length();
        if (y >= 0) {
            StringBuffer sb = new StringBuffer();
            char[] c = parameter.toCharArray();
            for(int i =0;i<y;i++){
                if(c[i] != ' '){
                      sb.append(c[i]);
                }
            }
            return sb.toString();
        } else {
            return parameter;
        }
    }
    public static String getName(String parameter){
        if(StringUtil.isNullOrBlankString(parameter))return null;
        parameter = parameter.trim();
        parameter = TextConverter.toEnglish(parameter).toUpperCase();
        int i = parameter.lastIndexOf(" ") + 1;
        parameter = parameter.substring(i);
        return parameter;
    }

    public static Vector<String> subStr(String text, String split){
		Vector<String> list = new Vector<String>();
		Integer len = split.length();
		Integer index = text.indexOf(split);
		while(index >= 0){
			String str1 = text.substring(0,index);
			String str2 = text.substring(index+len);
			list.add(str1);
			if(str2!=null && str2.length()>0){
				text = str2;
				index = text.indexOf(split);
			}else{ 
				index = -10;
			}
			if(index == -1){
				list.add(str2);
				break;
			}
		}
		return list;
	}
        
    public static String formatMoney(String money) {
		int len = money.trim().length();
		int total;
		if(money.length()%3 == 0) total = money.length()/3;
		else total = money.length()/3+1;
		Vector<String> list = new Vector<String>();
		for(int i = 0; i<total; i++){
			if(len<3){
				list.add(money);
			}else{
				list.add(money.substring(len-3, len));
				money = money.substring(0,len-3);
				len = money.trim().length();
			}
		}
		String format="";
		for(int i = list.size()-1; i>=0; i--){
			if(i == 0){
				format += list.get(i);
			}else
				format += list.get(i)+".";
		}
		return format + " VNĐ";
	}
    
    public static String getFileWithoutExtension(String fileName){
		int index = fileName.lastIndexOf(".");
		String fileNameWithoutExtension = null;
		if (index>0 && index <= fileName.length() - 2) {
			fileNameWithoutExtension = fileName.substring(0,index);
		}
		return fileNameWithoutExtension;
	}
    
    public static String getExtension(String fileName){
		int index = fileName.lastIndexOf(".");
		String extension = "";
		if (index>0 && index <= fileName.length() - 2) {
			extension = fileName.substring(index+1,fileName.length());
		}
		return extension;
	}

    /**
     * @author Tidus
     * @param name
     * @param max
     * @param min
     * @category valid ten tieng viet
     * @return
     */
    public static boolean isValidName(String name,Integer max,Integer min) {
//		String regex  = "^[\u0061-\u007A\u0041-\u005A\u0020\u00E0-\u017F\u1E00-\u1EFF\u0180-\u024F\u0080-\u00FF]{"+min+","+max+"}$";
    	String regex = "^[\u0061-\u007A\u0041-\u005A\u0020" +
		    			"\u00C0-\u00C3" + "\u00C8-\u00CA\u00CC\u00CD" + "\u00D2-\u00D5" + "\u00D9\u00DA\u00DD" +
		    			"\u00E0-\u00E3" + "\u00E8-\u00EA\u00EC\u00ED" + "\u00F2-\u00F5" + "\u00F9\u00FA\u00FD" +
		    			"\u0102\u0103\u0110\u0111\u0128\u0129\u0168\u0169" + "\u01A0\u01A1\u01AF\u01B0" + 
		    			"\u1EA0-\u1EF9]" + "{"+min+","+max+"}$";
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(name);
		if(matcher.matches()){
			return true;
		}else{
			return false;
		}
	}
    
    
    /**
     * @author Tidus
     * @param str
     * @category valid text Viet(ko nhap ki tu dac biet ~`'!@#$%^&*+=|\?/<>{}[])
     * @return
     */
    public static boolean isValidTxtVN(String str, int max, int min){
    	String regex = "^[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u0020\\u0022\u0028\u0029\u002B-\u002E\u003A\u003B\u005F" +
    			"\u00C0-\u00C3" + "\u00C8-\u00CA\u00CC\u00CD" + "\u00D2-\u00D5" + "\u00D9\u00DA\u00DD" +
    			"\u00E0-\u00E3" + "\u00E8-\u00EA\u00EC\u00ED" + "\u00F2-\u00F5" + "\u00F9\u00FA\u00FD" +
    			"\u0102\u0103\u0110\u0111\u0128\u0129\u0168\u0169" + "\u01A0\u01A1\u01AF\u01B0" + 
    			"\u1EA0-\u1EF9]" + "{"+min+","+max+"}$";
    	Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(str);
		if(matcher.matches()){
			return true;
		}else{
			return false;
		}
    }
    
    /**
     * @author Tidus
     * @param str
     * @category valid emId = 'NV-...'
     * @return
     */
    public static boolean isValidEmId(String emId){
    	String regex = "^(NV-)?\\d{4}$";
    	Pattern pattern = Pattern.compile(regex,Pattern.CASE_INSENSITIVE);
    	Matcher matcher = pattern.matcher(emId);
    	if(matcher.matches()){
    		return true;
    	}else return false;
    }

    public static boolean isValidCMTND(String str) {
		String regex = "^\\d{9}$";
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(str); 
		if(matcher.matches()){
			return true;
		}else{
			return false;
		}
	}
    public static boolean isValidNumber(String str) {
    	String s=str;
    	for (int i = 0; i < s.length(); i++) {
    	//If we find a non-digit character we return false.
    	if (!Character.isDigit(s.charAt(i)))
    	return false;
    	}
    	return true;
	}
	public static boolean isValidPhone(String phone){
		String regexPhone1 = "^(04|08){1}[2-7]{1}\\d{7}$";
		String regexPhone2 = "^((0){1}[1-9]{1}[0-9]{1,2}){1}[2-7]{1}\\d{6}$";
		Pattern pattern1 = Pattern.compile(regexPhone1);
		Pattern pattern2 = Pattern.compile(regexPhone2);
		Matcher matcher1 = pattern1.matcher(phone); 
		Matcher matcher2 = pattern2.matcher(phone);
		if(matcher1.matches() || matcher2.matches()){
			return true;
		}else{
			return false;
		}
	}
	
	/**
     * This method confirm condition get information from and validate phone
     * number
     *
     * @throws NumberFormatException
     *             return number confirm
     */
    public static boolean isValidMobile(String mobile){
		boolean isValid = false;   
		String numPhon1 = "^(09){1}\\d{8}$";  
		String numPhon2 = "^(01){1}\\d{9}$";
		Pattern pattern = Pattern.compile(numPhon1);  
		Pattern pattern2 = Pattern.compile(numPhon2);
		
		Matcher matcher = pattern.matcher(mobile); 
		Matcher matcher2 = pattern2.matcher(mobile);
		
		if(matcher.matches() || matcher2.matches()){  
			isValid = true;  
		}  
		return isValid;  
	}
    
    public static boolean isValidEmail(String str) {
        // Pattern uses confirm Email
        String regex = "^([a-zA-Z0-9_\\.])+\\@(([a-zA-Z0-9-])+\\.)+([a-zA-Z]{2,4})$";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(str);
        return m.matches();
    }
    
    public static boolean isValidUserName(String str){
    	String regex = "^(([a-zA-Z])+([0-9_\\.])*){3,100}$";
    	Pattern pattern = Pattern.compile(regex);
    	Matcher matcher = pattern.matcher(str);
    	if(matcher.matches()){
    		str = str.replaceAll("\\.", "");
    		str = str.replaceAll("_", "");
    		if(str.toLowerCase().contains("admin")) return false;
    		else return true;
    	}else return false;
    }
    
    public static boolean isValidRoleName(String str){
    	String regex = "^(([A-Za-z])+([0-9\\.])*){3,100}$";
    	Pattern pattern = Pattern.compile(regex);
    	Matcher matcher = pattern.matcher(str);
    	if(matcher.matches()){
    		str = str.replaceAll("\\.", "");
    		if(str.toLowerCase().contains("admin")) return false;
    		else return true;
    	}else return false;
    }
    
    public static String removeUnwantedSpace(String str){
    	if(str == null) return null;
    	str = str.trim();
    	String regex = "\\s+";
    	str = str.replaceAll(regex, " ");
    	return str;
    }
    
    public static String removeAllSpace(String str){
    	if(str == null) return null;
    	str = str.trim();
    	String regex = "\\s+";
    	str = str.replaceAll(regex, "");
    	return str;
    }
    
    public static String removeColon(String str){
    	if(str == null) return null;
    	str = str.replace(":", "");
    	return str.trim();
    }
    
    public static boolean isValidNumber(String number, int min, int max){
    	String regex = "\\d+";
    	Pattern p = Pattern.compile(regex);
    	Matcher m = p.matcher(number);
    	if(m.matches()){
    		if(min == -1 && max == -1){
    			return true;
    		}else{
    		int num = Integer.valueOf(number);
    			if(min == -1){
    				if(num <= max) return true;
    				else return false;
    			}else if(max == -1){
    				if(num >= min) return true;
    				else return false;
    			}
	    		if(num >= min && num <=max) return true;
	    		else return false;
    		}
    	}else return false;
    }
    
    public static boolean isValidPwd(String pwd){
    	boolean flag = true;
    	if(pwd.length() < 6) return false;
    	for(int i=0; i<pwd.length(); i++){
    		int charCode = (int) pwd.charAt(i);
    		if(charCode > 126 || charCode < 33 || charCode == 34 || 
    				charCode == 39 || charCode == 45 || charCode == 47){
    			flag = false;
    			break;
    		}
    	}
    	return flag;
    }
    
    public static String randomPwd(int n){
    	String pwd = "";
    	int min = 33;
    	int max = 126;	//[34 "] [39 '] [45 -] [47 /]
    	for(int i=0; i<n; i++){
	    	int charCode = (int) (min+Math.round(Math.random()*(max-min)));	    	
	    	if(charCode == 34 || charCode == 39 || charCode == 45 || charCode == 47){
	    		i--;
	    	}else{
	    		char c = (char)charCode;
	    		pwd += c;
	    	}
    	}
    	return pwd;
    }
    
    public static String setFilterIllegal(String str){
    	if(str == null || str.isEmpty()) return str ="";
    	str = str.trim();
    	str = str.replaceAll("\"", "&#34;");
    	str = str.replaceAll("\'", "&#39;");
    	str = str.replaceAll("-", "&#45;");
    	str = str.replaceAll("/", "&#47;");
    	return str;
    }
    
    public static String getFilterIllegal(String str){
    	if(str == null || str.isEmpty()) return str ="";
    	str = str.trim();
    	str = str.replaceAll("&#34;", "\"");
    	str = str.replaceAll("&#39;", "\'");
    	str = str.replaceAll("&#45;", "-");
    	str = str.replaceAll("&#47;", "/");
    	return str;
    }
    
    /**
     * @author Tidus
     * @param Vector<String> listSrc
     * @param count: số lần nhân bản
     * @return Vector<String> dupliStr: số lần nhân bản
     */
    public static Vector<String> duplicate(Vector<String> listSrc, int count){
    	Vector<String> dupliStr = new Vector<String>();
    	for(int i=0; i<count; i++){
    		for(int j=0; j<listSrc.size(); j++){
    			dupliStr.add(listSrc.get(j));
    		}
    	}
    	return dupliStr;
    }

	
	public static void main(String[] args) {
	    String name1 = "Nhà Xuất bản Bách Khoa Đào tạo Quốc Tế giải thuật cấu trúc dữ liệu";
	    String cmtnd = "123456789";
	    String mobile1 = "01698152005";
//	    String mobile2 = "0914565567";
//	    String email1 = "tidus_eternal@yahoo.com";
	    String email2 = "sontt.c1007m@gmail.abc.com";
	    String phone1 = "0438639435";
//	    String phone2 = "03203863943";

	    System.out.println("isValidPhone: "+isValidPhone(phone1));
	    System.out.println("isValidEmail: "+isValidEmail(email2));
	    System.out.println("isValidMobile: "+isValidMobile(mobile1));
	    System.out.println("isValidName: "+isValidName(name1, 200, 2));
	    System.out.println("isValidCMTND: "+isValidCMTND(cmtnd));
	    String str = "		ab 	 	c		  d		e	   f		";
	    str = removeUnwantedSpace(str);
	    System.out.println(str);
	    String str1 = "Nhân viên : ";
	    System.out.println(removeColon(str1));
	    System.out.println(isValidEmId("nV-0010"));	    
	    
	    System.out.println(removeAllSpace(TextConverter.toEnglish(str1)).toUpperCase());
	    
	    System.out.println(isValidTxtVN("34A. ngõ 93-đường Hoàng Mai", 250, 3));
	    System.out.println(isValidUserName("a12bd123.5_6"));
	    System.out.println(isValidRoleName("a.d..m.in456"));
	    
	    System.out.println(randomPwd(8));
	    System.out.println(isValidPwd("!@$!@%%^'&agasgg"));
	    
	    String txt = "'\"-/sagasg'sag\"-/";
	    System.out.println(setFilterIllegal(txt));
	    System.out.println(getFilterIllegal(setFilterIllegal(txt)));
	    
	    System.out.println(getExtension("C:/a.g.txt.jpg"));
	    
	    Vector<String> listSrc = new Vector<String>();
	    listSrc.add("a");
	    listSrc.add("b");
	    listSrc.add("c");
	    Vector<String> dupliStr = duplicate(listSrc, 3);
	    for(int i=0; i<dupliStr.size(); i++){
	    	System.out.println(dupliStr.get(i));
	    }
//		Vector<String> old = new Vector<String>();
//		old.add("1");
//		old.add("2");
//		old.add("3");
//		old.add("5");
//		old.add("7");
//		Vector<String> newStrings = new Vector<String>();
//		newStrings.add("3");
//		newStrings.add("5");
//		newStrings.add("4");
//		newStrings.add("2");
//		newStrings.add("8");
//		newStrings.add("1");
//		
//		Vector<String> index = new Vector<String>();
//		for(int i=0; i<newStrings.size(); i++){
//			for(int j=0; j<old.size(); j++){
//				if(newStrings.get(i).equals(old.get(j))){
//					index.add(newStrings.get(i));
//				}
//			}
//		}	
//		for(int i=0; i<index.size(); i++){
//			newStrings.remove(index.get(i));
//			old.remove(index.get(i));
//		}
//		for(int i=0; i<newStrings.size(); i++){
//			System.out.println(newStrings.get(i));
//		}
//		System.out.println("-------------");
//		for(int i=0; i<old.size(); i++){
//			System.out.println(old.get(i));
//		}
		
	}

}


